//
//  MyTableViewCell.swift
//  MyKebiao
//
//  Created by David on 2016/12/2.
//  Copyright © 2016年 David. All rights reserved.
//

import UIKit

class KBTableViewCell: UITableViewCell {

    var items:[UIView] = []
    
    init(rowNum: Int, width: CGFloat, reuseID: String?){
        super.init(style: .default, reuseIdentifier: reuseID)
        
        self.backgroundColor = UIColor.clear
        
        if rowNum == 0{
            let itemWidth = (width - CGFloat(TABLE_SIDER_WIDTH))/7
            for i in 0..<7{
                let itemLabel = UILabel()
                itemLabel.font = UIFont.systemFont(ofSize: 12)
                itemLabel.numberOfLines = 0
                itemLabel.backgroundColor = UIColor.white
                itemLabel.textAlignment = .center
                itemLabel.text = _get_weekday(num: i, starter: 1)
                itemLabel.frame = CGRect(x: CGFloat(TABLE_SIDER_WIDTH) + CGFloat(i)*itemWidth, y: 0, width: itemWidth, height: CGFloat(TABLE_HEADER_HEIGHT))
                
                addSubview(itemLabel)
                items.append(itemLabel)
            }
        }else{
            let numLabel = UILabel(frame: CGRect(x: 0, y: 0, width: TABLE_SIDER_WIDTH, height: ITEM_HEIGHT))
            numLabel.backgroundColor = UIColor.white
            numLabel.textAlignment = .center
            numLabel.font = UIFont.systemFont(ofSize: 12)
            addSubview(numLabel)
            numLabel.text = "\(rowNum)"
            let itemWidth = (width - CGFloat(TABLE_SIDER_WIDTH))/7
            for i in 0..<7{
                let itemView = UIView()
                
                itemView.frame = CGRect(x: CGFloat(TABLE_SIDER_WIDTH) + CGFloat(i)*itemWidth, y: 0, width: itemWidth, height: CGFloat(ITEM_HEIGHT))
                itemView.backgroundColor = UIColor.clear
                
                addSubview(itemView)
                items.append(itemView)
            }
        }
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
